# _*_ coding: UTF-8 _*_
# @Time     : 2021/10/25 10:41
# @Author   : Gong Yangyi
# @Site     : http://www.hzdledu.cn/
# @File     : c6s3_sequence序列.py
# @Software : PyCharm
#序列的操作
#1.序列的索引操作
list1 = [1,2,3]
tuple1 = (1,2,3)
print(list1[-1])
print(tuple1[-1])

list2=[
    [1,2,3],
    [4,5,6],
    [7,8,9]
]
print(list2[0][2])
print(list2[1][2])
print(list2[2][2])

for i in list2:
    for j in i:
        print(j,end=',')
        print()
#2.序列的切片
list1=[1,2,3,4,5,6]
tuple1=(1,2,3,4,5,6)
print(list1[1:2])#[2]
print(tuple1[:2])#（(1,2)
print(list1[1:]) #[2,3,4,5,6]
print(tuple1[::2]) #(1,3,5)
#3.序列
list1=[1,2,3]
list2=[4,5,6]
list3=list1+list2
print(list3)
#4.操作序列的函数